package com.example.sleuth;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

@org.springframework.web.bind.annotation.RestController
public class RestController {
    private static final Log log = LogFactory.getLog(RestController.class);

    @Autowired
    private RestTemplate restTemplate;

    @Value("${app.url:http://localhost:${local.server.port:${server.port:6000}}}")
    private String url;

    @RequestMapping("/")
    public String home() {
        log.info("Home");
        String s = this.restTemplate.getForObject(url + "/hi", String.class);
        return "hi/" + s;
    }
    @RequestMapping("/hi")
    public String hi() {
        log.info("Hi");
        return "hi";
    }

}

